'use strict';

const { Controller } = require('egg');

class AdminController extends Controller {

  async list() {
    const { ctx } = this;
    const listInfo = await ctx.model.Admins.findAll();
    ctx.body = listInfo;
  }

  async findDetails() {
    const { ctx } = this;
    const { uuid } = this.ctx.request.query;
    const adminInfo = await ctx.model.Admins.findOne({
      where: { uuid },
    });
    ctx.body = adminInfo;
  }

  async create() {
    const { ctx } = this;
    // const demo = {
    //   name: '嬴政',
    //   age: 41,
    //   is_able: true,
    //   province_code: 42,
    //   county_code: 32,
    //   city_code: 12,
    //   address: '中古',
    //   id_number: "320102199503076321"
    // }
    // const admin = await ctx.model.Admins.create({
    //   ...demo
    // });
    const serviceAdmin = await ctx.service.admins.create();
    ctx.status = 200;
    ctx.body = serviceAdmin;
  }
}


module.exports = AdminController;

